home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
19
/
madtrb11.zip
/
PWRR.INC
< prev
next >
Wrap
Text File
|
1986-01-21
|
1KB
|
46 lines
Function PwrR(x,y : real): real;
{Written by Paul F. Hultquist. Found in May 1985 PC Tech Journl }
{PwrR finds X (real) to the power Y (real) using logarithms and exponentials.}
{If Y is an integer PwrI is faster. The function eliminates the undefined }
{cases, and the case where the result is complex. }
Begin
if x > 0 then
PwrR := exp(y*ln(x))
else
if x < 0 then
begin
writeln('x < 0. Halt.');
Halt;
end
else
if (x = 0) and (y = 0) then
begin
writeln('0 to the 0 power. Halt.');
Halt;
end
else
if (x = 0) and (y < 0) then
begin
writeln('0 to a negative power. Halt.');
Halt;
end
else
PwrR := 0.0;
End; {PwrR}function Mpwr(num : real; expon : integer): real;
Var
M : real;
I : integer;
begin
M := num;
for I := 2 to expon do
num := num * M;
Mpwr := num;
end; {Rpwr}
function Rpwr(num : real; expon : integer): real;
begin
if expon = 0 then Rpwr :=1
else
Rpwr := num * Rpwr(num, expon - 1);
end; {Rpwr}